package com.guoheng.hazard.sys.controller.entpr;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.entpr.ProductionPlaceInsertDTO;
import com.guoheng.hazard.sys.model.dto.entpr.ProductionPlaceUpdateDTO;
import com.guoheng.hazard.sys.service.entpr.ProductionPlaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　ProductionPlaceController
 *
 * @author fbl
 * @date 2019-11-13 17:45
 */
@RestController
@Validated
@Api(value = "生产场所信息")
public class ProductionPlaceController {

    @Resource
    ProductionPlaceService productionPlaceService;

    @ApiOperation(value = "查询企业生产场所信息")
    @GetMapping(value = "data/basic/enterprise/place")
    public Result getPlace(String entprName, String placeNo, Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return productionPlaceService.getPlace(entprName, placeNo, entprId, pageNum, pageSize);
    }

    @ApiOperation(value = "修改企业生产场所信息")
    @PutMapping(value = "data/basic/enterprise/place")
    public Result updatePlace(@RequestBody @Valid ProductionPlaceUpdateDTO productionPlaceUpdateDTO) {
        return productionPlaceService.updatePlace(productionPlaceUpdateDTO);
    }

    @ApiOperation(value = "新增企业生产场所信息")
    @PostMapping(value = "data/basic/enterprise/place")
    public Result insertPlace(@RequestBody @Valid ProductionPlaceInsertDTO productionPlaceInsertDTO) {
        return productionPlaceService.insertPlace(productionPlaceInsertDTO);
    }

    @ApiOperation(value = "删除企业生产场所信息")
    @DeleteMapping(value = "data/basic/enterprise/place/{id}")
    public Result deletePlace(@PathVariable @NotNull Long id) {
        return productionPlaceService.deletePlace(id);
    }

    @ApiOperation(value = "查询企业生产场所信息详情")
    @GetMapping(value = "data/basic/enterprise/place/{id}")
    public Result getPlaceById(@PathVariable @NotNull Long id) {
        return productionPlaceService.getPlaceById(id);
    }

}